package com.ddd.infrastructure.common;

import java.io.Serializable;

/**
 * 描述通用返回类Result
 * 在前后端分离的项目中，为了统一接口返回参数，需要封装一个通用的返回类Result。
 */
public class Result<T> implements Serializable  {
    private static final long serialVersionUID = 1L;

    private String code;
    private String msg;
    private  transient T data;

    public Result() {
    }

    public Result(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public Result<T> setCode(String code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public Result<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
